<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-wrap align-center justify-center benben-position-layout flex passwordLogin_flex_0" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class=""></view>
				<view class="title_text">绑定手机号</view>
				<view class=""></view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="title_bg"></view>
			
			<view class="store_info">
				<view class="store_1">中出行租车（东站新店）</view>
				<view class="store_2">中出行租车·真的好租</view>
				<image :src='STATIC_URL+"284.png"'></image>
			</view>
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout passwordLogin_flex_2">
				<!-- <text class='passwordLogin_fd2_0'>申请获取以下权限</text>
				<text class='passwordLogin_fd2_1'>获取你的公开信息（昵称、头像、地区等）</text> -->
				<button class='flex flex-wrap align-center justify-center passwordLogin_fd2_2' @getphonenumber="getPhoneNumber">
					<text class='passwordLogin_fd2_2_c1'>绑定手机号</text>
				</button>
			</view>
			
		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"is_tick": false,
				"code": "",
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			uni.login({
				success: res => {
					console.log(res);
					this.code = res.code;
				}
			});
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 获取手机号
			getPhoneNumber(e) {
				console.log(e);
				if (e.detail.errMsg.indexOf("user deny") !== -1) {
					uni.navigateBack();
				} else {
					this.bindMoblile(e.detail.encryptedData, e.detail.iv);
				}
			},
			bindMoblile(encryptedData, iv) {
				uni.showLoading({
					title: '绑定中...'
				})
				uni.getUserInfo({
					provider: 'weixin',
					success: infoRes => {
						if (this.code) {
							this.$api.post(global.apiUrls.post5e497dd94fcaf, {
									encryptedData: encryptedData,
									iv: iv,
									code: this.code,
								}).then(res => {
									let result = res.data;
									uni.hideLoading();
									if (result.code == 1) {
										this.$message.info(result.msg);
										// uni.removeStorageSync('Wxinfo_tmp');
										this.$store.commit('updateUserInfo', result.data.userinfo);
										this.$store.commit('saveToken', result.data.userinfo.user_token);
			
										setTimeout(() => {
											uni.switchTab({
												url: '/pages/tabBar/index/index'
											})
										}, 800)
			
									} else {
										this.$message.info(result.msg);
									}
								})
								.catch(err => {
									uni.hideLoading();
									console.log('ERROR', err);
								})
						} else {
							uni.hideLoading();
							this.$message.info('授权失败');
						}
					},
					fail: err => {
						uni.hideLoading();
						console.log('ERROR', err)
					}
				});
			},
		}
	};
</script>
<style lang="scss" scoped>
	.title_bg {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 508rpx;
		// background: linear-gradient( 180deg, #FFE5D7 100%, #FFFFFF 100%);
		background: linear-gradient(to bottom, #FFE5D7, #FFFFFF);
	}
	.store_info {
		position: relative;
		z-index: 10;
		text-align: center;
		.store_1 {
			font-weight: bold;
			font-size: 48rpx;
			color: #111111;
		}
		.store_2 {
			margin-top: 8rpx;
			font-weight: 400;
			font-size: 34rpx;
			color: #666666;
		}
		image {
			width: 640rpx;
			height: 640rpx;
		}
	}
	.title_text {
		font-weight: bold;
		font-size: 32rpx;
		color: #111111;
	}
	.set_fd3_0 {
		line-height: 50rpx;
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		margin: 40rpx 0rpx 32rpx 0rpx;
		text-align: center;
	}
	
	.set_fd3_1 {
		line-height: 45rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 0rpx 37rpx 0rpx;
		text-align: center;
		padding: 0 30rpx;
	}
	
	.set_fd3_2_c0 {
		border-top: 1px solid #eee;
		border-right: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		width: 269rpx;
		height: 94rpx;
		line-height: 94rpx;
		font-weight: 500;
	}
	
	.set_fd3_2_c1 {
		border-top: 1px solid #eee;
		border-left: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: #1593FF;
		width: 269rpx;
		height: 94rpx;
		line-height: 94rpx;
		font-weight: 500;
	}
	
	.set_flex_3 {
		background: #fff;
		background-size: 100% !important;
		width: 540rpx;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	
	.set_fd2_0 {
		border: 1px solid #BFBFBF;
		background: rgba(255, 255, 255, 0.3900);
		background-size: 100% !important;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #333;
		width: 686rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 500;
	}
	
	.set_flex_2 {
		width: 750rpx;
		height: 144rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}
	.tourist {
		font-size: 28rpx;
		color: #2BA5FF;
		margin-top: 32rpx;
		text-align: center;
	}
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
	}

	.passwordLogin_flex_0 {
		width: 750rpx;
		height: 88rpx;
		position: relative;
		z-index: 10;
	}

	.passwordLogin_flex_1 {
		padding: 90rpx 0rpx 147rpx 0rpx;
	}

	.passwordLogin_fd1_1 {
		color: #333333;
		font-size: 36rpx;
		font-weight: 500;
	}

	.passwordLogin_fd1_0 {
		width: 180rpx;
		height: 180rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
		border-radius: 16rpx;
	}

	.passwordLogin_flex_2 {
		padding: 0rpx 55rpx 0rpx 55rpx;
		position: relative;
		z-index: 10;
	}

	.passwordLogin_fd2_2_c1 {
		font-weight: bold;
		font-size: 30rpx;
		color: #FFFFFF;
	}

	.passwordLogin_fd2_2 {
		width: 640rpx;
		height: 98rpx;
		background: linear-gradient( 90deg, #FD9602 0%, #FC5B03 100%);
		border-radius: 16rpx;
	}

	.passwordLogin_fd2_1 {
		color: #808080;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
		margin: 0rpx 0rpx 40rpx 0rpx;
	}

	.passwordLogin_fd2_0 {
		color: #1A1A1A;
		font-size: 32rpx;
		font-weight: 700;
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.passwordLogin_flex_3 {
		background: #fff;
		width: 750rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto !important;
		margin-top: 64rpx;
	}

	.passwordLogin_fd3_2 {
		font-weight: 500;
		font-size: 24rpx;
		color: #FC5B03;
		text-decoration: underline;
		margin: 0 5rpx;
	}

	.passwordLogin_fd3_1 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.passwordLogin_noCheckfd3_0_c1_c0 {
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		width: 32rpx;
		height: 32rpx;
		margin: 6rpx 0rpx 0rpx 0rpx;
	}

	.passwordLogin_checkfd3_0_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		margin: 6rpx 0rpx 0rpx 0rpx;
	}

	::v-deep .passwordLogin_fd3_0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		transform: translateY(-3rpx);
	}
</style>